<#include "/generation-templates/directive/contains.ftl"/>
import { get, post, put, del } from '@/utils/request';
import { <@contains tableInfo = table rules = "enum">ENUMS_PATH, </@contains>EXCEL_DATA_PATH } from '@/constant/system/api-constants';

// 请求uri
const requestUri = '/sys/${table.getKebabName()}';

export function get${table.getCamelName()}List({ page, size }, query = {}) {
  return get(requestUri, Object.assign({
    page: page - 1,
    size
  }, query));
}

<@contains tableInfo = table rules = "enum">
export function getEnums() {
  return get(requestUri + ENUMS_PATH);
}

</@contains>
export function getExportedData(query) {
  return get(requestUri + EXCEL_DATA_PATH, query);
}

export function add${table.getCamelName()}(data) {
  return post(requestUri, data);
}

export function modify${table.getCamelName()}(data) {
  return put(requestUri, data);
}

export function delete${table.getCamelName()}(params) {
  return del(requestUri, params);
}

// 控制权限
export default {
  add${table.getCamelName()}: [requestUri, 'post'],
  modify${table.getCamelName()}: [requestUri, 'put'],
  delete${table.getCamelName()}: [requestUri, 'delete'],
  getExportedData: [requestUri + EXCEL_DATA_PATH, 'get']
};
